layui.use(['form', 'element', 'upload', 'jquery'], function () {
    var form = layui.form;
    var upload = layui.upload;
    var element = layui.element;
    var $ = layui.jquery;
    upload.render({
        elem: '#updateImg',
        url: "/upload/uploadFile",
        field: "files",
        accept: "images",
        acceptMime: 'image/*',
        done: function (res, index, upload) {
            if (res.code == 0) {
                var avatarUrl = res.data.path;
                $('#avatarUrl').attr('src', avatarUrl);
                $('input[name=avatarUrl]').val(avatarUrl);
            }
        },
        progress: function (n, elem, e) {
            element.progress('demo', n + '%');
            if (n == 100) {
                layer.msg('上传完毕', {icon: 1});
            }
        }
    });
})
